package com.xiaochang.em.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.Locale;

/**
 * 文件配置信息
 */
@Component
@Configuration
@PropertySource(value = "classpath:file.properties")
public class FileConfig {

    @Value("${read.basePath}")
    private String basePath;

    @Value("${read.basePath.linux}")
    private String basePathLinux;

    @Value("${read.avatarPath}")
    private String avatarPath;

    @Value("${read.filePath}")
    private String filePath;

    public String getBasePath(){
        if(isLinux()){
            return basePathLinux;
        }
        return basePath;
    }

    public String getAvatarPath() {
        return getBasePath() + avatarPath;
    }

    public String getFilePath() {
        return getBasePath() + filePath;
    }

    public boolean isLinux(){
        return System.getProperty("os.name").toLowerCase().contains("linux");
    }

}
